package com.itheima.fanxing;

import com.itheima.domain.Student;

public class Demo06 {

    public static void main(String[] args) {
        InterImpl<String> inter = new InterImpl<>();
        inter.sing("abc");
        String dance = inter.dance();
        System.out.println(dance);
        Inter<Student> inter1 = new InterImpl<>();
        inter1.sing(new Student("zhangsan ",25));
        System.out.println(inter1.dance());



        InterImpl2 interImpl2 = new InterImpl2();
        interImpl2.sing("abc");
        System.out.println(interImpl2.dance());

    }
}
//泛型接口
interface Inter<T>{
    void sing(T t);
    T dance();
}
//泛型类  第一种写法 将父类的泛型继承下来   也得声明
class InterImpl<T> implements Inter<T>{
    private T t;

    @Override
    public void sing(T t) {
        this.t=t;
    }

    @Override
    public T dance() {
        return t;
    }
}
// 不装了,摊牌了   直接明确泛型  后面就不管了
class InterImpl2 implements Inter<String>{

    @Override
    public void sing(String s) {
        System.out.println(s);
    }

    @Override
    public String dance() {
        return "hahaha";
    }
}